10 //Verdadero si las sumas internas de [start, end] están correctas.
11 bool todo_bien(int start
, int end
, const vector
<ll
> &v
, const vector
<int> &jmp
){
17 if (todo_bien(i
, jmp
[i
], v
, jmp
) == false) return false;
21 //cout << "Todo_bien entre " << start << " , " << end << ", sum = " << sum << " ans = " << (sum < v[end]) << endl;
22 return (sum
< v
[end
]);
27 while (getline(cin
, line
)){
29 stack
<pair
<ll
, int> > stk
;
33 stringstream
sin(line
);
40 stk
.push(make_pair(x
, i
));
42 if (stk
.size() == 0) bad
= true;
44 ll y
= stk
.top().first
;
45 int j
= stk
.top().second
;
55 if (stk
.size()) bad
= true;
56 if (bad
|| !todo_bien(0, i
-1, v
, jmp
)) cout
<< ":-( Try again." << endl
;
57 else cout
<< ":-) Matrioshka!" << endl
;